[FORMAT "WCOFF"]
[INSTRSET "i486p"]
[OPTIMIZE 1]
[OPTION 1]
[BITS 32]
	EXTERN	_memman_alloc_4k
	EXTERN	_memman_free_4k
[FILE "sheet.c"]
[SECTION .text]
	GLOBAL	_shtctl_init
_shtctl_init:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EDI
	PUSH	ESI
	PUSH	EBX
	MOV	ESI,DWORD [8+EBP]
	PUSH	11284
	MOV	EDI,DWORD [16+EBP]
	PUSH	ESI
	CALL	_memman_alloc_4k
	MOV	EBX,EAX
	POP	EAX
	POP	EDX
	TEST	EBX,EBX
	JE	L3
	MOV	EAX,DWORD [20+EBP]
	IMUL	EAX,EDI
	SAL	EAX,2
	PUSH	EAX
	PUSH	ESI
	CALL	_memman_alloc_4k
	TEST	EAX,EAX
	MOV	DWORD [4+EBX],EAX
	POP	EDX
	POP	ECX
	JE	L11
	MOV	EAX,DWORD [12+EBP]
	MOV	DWORD [8+EBX],EDI
	MOV	DWORD [EBX],EAX
	LEA	EDX,DWORD [10200+EBX]
	MOV	EAX,DWORD [20+EBP]
	MOV	DWORD [12+EBX],EAX
	MOV	EAX,EBX
	MOV	DWORD [16+EBX],-1
L9:
	MOV	DWORD [1072+EAX],0
	MOV	DWORD [1076+EAX],EBX
	ADD	EAX,40
	CMP	EAX,EDX
	JLE	L9
L3:
	LEA	ESP,DWORD [-12+EBP]
	MOV	EAX,EBX
	POP	EBX
	POP	ESI
	POP	EDI
	POP	EBP
	RET
L11:
	PUSH	11284
	PUSH	EBX
	PUSH	ESI
	CALL	_memman_free_4k
	ADD	ESP,12
	JMP	L3
	GLOBAL	_sheet_alloc
_sheet_alloc:
	PUSH	EBP
	XOR	EDX,EDX
	MOV	EBP,ESP
	MOV	EAX,DWORD [8+EBP]
	ADD	EAX,1044
L18:
	CMP	DWORD [28+EAX],0
	JE	L21
	INC	EDX
	ADD	EAX,40
	CMP	EDX,255
	JLE	L18
	XOR	EAX,EAX
L12:
	POP	EBP
	RET
L21:
	MOV	DWORD [28+EAX],1
	MOV	DWORD [24+EAX],-1
	MOV	DWORD [36+EAX],0
	JMP	L12
	GLOBAL	_sheet_setbuf
_sheet_setbuf:
	PUSH	EBP
	MOV	EBP,ESP
	MOV	EDX,DWORD [8+EBP]
	MOV	EAX,DWORD [12+EBP]
	MOV	DWORD [EDX],EAX
	MOV	EAX,DWORD [16+EBP]
	MOV	DWORD [4+EDX],EAX
	MOV	EAX,DWORD [20+EBP]
	MOV	DWORD [8+EDX],EAX
	MOV	EAX,DWORD [24+EBP]
	MOV	DWORD [20+EDX],EAX
	POP	EBP
	RET
	GLOBAL	_sheet_refreshmap
_sheet_refreshmap:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EDI
	PUSH	ESI
	PUSH	EBX
	SUB	ESP,40
	MOV	EAX,DWORD [8+EBP]
	CMP	DWORD [12+EBP],0
	MOV	EAX,DWORD [4+EAX]
	MOV	DWORD [-40+EBP],EAX
	JS	L68
L24:
	CMP	DWORD [16+EBP],0
	JS	L69
L25:
	MOV	EDX,DWORD [8+EBP]
	MOV	EAX,DWORD [8+EDX]
	CMP	DWORD [20+EBP],EAX
	JLE	L26
	MOV	DWORD [20+EBP],EAX
L26:
	MOV	EBX,DWORD [8+EBP]
	MOV	EAX,DWORD [12+EBX]
	CMP	DWORD [24+EBP],EAX
	JLE	L27
	MOV	DWORD [24+EBP],EAX
L27:
	MOV	EAX,DWORD [8+EBP]
	MOV	ESI,DWORD [28+EBP]
	MOV	DWORD [-16+EBP],ESI
	CMP	ESI,DWORD [16+EAX]
	JG	L61
L59:
	MOV	EBX,DWORD [8+EBP]
	MOV	EDX,DWORD [-16+EBP]
	MOV	ECX,DWORD [16+EBP]
	MOV	EDI,DWORD [20+EBX+EDX*4]
	MOV	EAX,EDI
	SUB	EAX,EBX
	MOV	ESI,DWORD [EDI]
	SUB	EAX,1044
	MOV	EDX,DWORD [16+EDI]
	SAR	EAX,3
	MOV	DWORD [-36+EBP],ESI
	IMUL	EAX,EAX,-858993459
	MOV	ESI,DWORD [24+EBP]
	SUB	ECX,EDX
	SUB	ESI,EDX
	MOV	DWORD [-44+EBP],EAX
	MOV	EBX,DWORD [20+EBP]
	MOV	EDX,DWORD [12+EBP]
	MOV	EAX,DWORD [12+EDI]
	MOV	DWORD [-32+EBP],ESI
	SUB	EBX,EAX
	SUB	EDX,EAX
	MOV	DWORD [-28+EBP],EBX
	MOV	DWORD [-24+EBP],EDX
	JS	L70
L32:
	TEST	ECX,ECX
	JS	L71
L33:
	MOV	EAX,DWORD [4+EDI]
	CMP	DWORD [-28+EBP],EAX
	JLE	L34
	MOV	DWORD [-28+EBP],EAX
L34:
	MOV	EAX,DWORD [8+EDI]
	CMP	DWORD [-32+EBP],EAX
	JLE	L35
	MOV	DWORD [-32+EBP],EAX
L35:
	CMP	DWORD [20+EDI],-1
	JE	L72
	MOV	EBX,ECX
	CMP	ECX,DWORD [-32+EBP]
	JGE	L30
L58:
	MOV	ESI,DWORD [16+EDI]
	MOV	ECX,DWORD [-24+EBP]
	ADD	ESI,EBX
	CMP	ECX,DWORD [-28+EBP]
	MOV	DWORD [-20+EBP],ESI
	JGE	L67
L57:
	MOV	EAX,DWORD [12+EDI]
	MOV	EDX,DWORD [-36+EBP]
	ADD	EAX,ECX
	MOV	ESI,DWORD [20+EDI]
	MOV	DWORD [-52+EBP],EAX
	MOV	EAX,EBX
	IMUL	EAX,DWORD [4+EDI]
	ADD	EAX,ECX
	CMP	DWORD [EDX+EAX*4],ESI
	JE	L54
	MOV	EDX,DWORD [8+EBP]
	MOV	EAX,DWORD [-20+EBP]
	MOV	ESI,DWORD [-40+EBP]
	IMUL	EAX,DWORD [8+EDX]
	ADD	EAX,DWORD [-52+EBP]
	MOV	EDX,DWORD [-44+EBP]
	MOV	DWORD [ESI+EAX*4],EDX
L54:
	INC	ECX
	CMP	ECX,DWORD [-28+EBP]
	JL	L57
L67:
	INC	EBX
	CMP	EBX,DWORD [-32+EBP]
	JL	L58
L30:
	MOV	ESI,DWORD [8+EBP]
	INC	DWORD [-16+EBP]
	MOV	EBX,DWORD [-16+EBP]
	CMP	EBX,DWORD [16+ESI]
	JLE	L59
L61:
	ADD	ESP,40
	POP	EBX
	POP	ESI
	POP	EDI
	POP	EBP
	RET
L72:
	MOV	EBX,ECX
	CMP	ECX,DWORD [-32+EBP]
	JGE	L30
L46:
	MOV	ESI,DWORD [16+EDI]
	MOV	ECX,DWORD [-24+EBP]
	ADD	ESI,EBX
	CMP	ECX,DWORD [-28+EBP]
	MOV	DWORD [-20+EBP],ESI
	JGE	L64
L45:
	MOV	EAX,DWORD [12+EDI]
	MOV	EDX,DWORD [8+EBP]
	ADD	EAX,ECX
	MOV	ESI,DWORD [-40+EBP]
	MOV	DWORD [-52+EBP],EAX
	INC	ECX
	MOV	EAX,DWORD [-20+EBP]
	IMUL	EAX,DWORD [8+EDX]
	ADD	EAX,DWORD [-52+EBP]
	MOV	EDX,DWORD [-44+EBP]
	CMP	ECX,DWORD [-28+EBP]
	MOV	DWORD [ESI+EAX*4],EDX
	JL	L45
L64:
	INC	EBX
	CMP	EBX,DWORD [-32+EBP]
	JL	L46
	JMP	L30
L71:
	XOR	ECX,ECX
	JMP	L33
L70:
	MOV	DWORD [-24+EBP],0
	JMP	L32
L69:
	MOV	DWORD [16+EBP],0
	JMP	L25
L68:
	MOV	DWORD [12+EBP],0
	JMP	L24
	GLOBAL	_sheet_refreshsub
_sheet_refreshsub:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EDI
	PUSH	ESI
	PUSH	EBX
	SUB	ESP,44
	MOV	EAX,DWORD [8+EBP]
	MOV	EDX,DWORD [8+EBP]
	CMP	DWORD [12+EBP],0
	MOV	EAX,DWORD [EAX]
	MOV	EDX,DWORD [4+EDX]
	MOV	DWORD [-36+EBP],EAX
	MOV	DWORD [-40+EBP],EDX
	JS	L104
L74:
	CMP	DWORD [16+EBP],0
	JS	L105
L75:
	MOV	ESI,DWORD [8+EBP]
	MOV	EAX,DWORD [8+ESI]
	CMP	DWORD [20+EBP],EAX
	JLE	L76
	MOV	DWORD [20+EBP],EAX
L76:
	MOV	EDI,DWORD [8+EBP]
	MOV	EAX,DWORD [12+EDI]
	CMP	DWORD [24+EBP],EAX
	JLE	L77
	MOV	DWORD [24+EBP],EAX
L77:
	MOV	EAX,DWORD [28+EBP]
	MOV	EDX,DWORD [32+EBP]
	MOV	DWORD [-16+EBP],EAX
	CMP	EAX,EDX
	JG	L99
L97:
	MOV	EDI,DWORD [8+EBP]
	MOV	ESI,DWORD [-16+EBP]
	MOV	ECX,DWORD [16+EBP]
	MOV	EBX,DWORD [20+EDI+ESI*4]
	MOV	ESI,DWORD [20+EBP]
	MOV	EAX,DWORD [EBX]
	MOV	EDX,DWORD [16+EBX]
	MOV	DWORD [-32+EBP],EAX
	SUB	ECX,EDX
	MOV	EAX,EBX
	SUB	EAX,EDI
	MOV	EDI,DWORD [24+EBP]
	SUB	EAX,1044
	SUB	EDI,EDX
	SAR	EAX,3
	MOV	EDX,DWORD [12+EBP]
	IMUL	EAX,EAX,-858993459
	MOV	DWORD [-44+EBP],EAX
	MOV	DWORD [-56+EBP],EDI
	MOV	EAX,DWORD [12+EBX]
	SUB	ESI,EAX
	SUB	EDX,EAX
	MOV	DWORD [-28+EBP],ESI
	MOV	DWORD [-24+EBP],EDX
	JS	L106
L82:
	TEST	ECX,ECX
	JS	L107
L83:
	MOV	EAX,DWORD [4+EBX]
	CMP	DWORD [-28+EBP],EAX
	JLE	L84
	MOV	DWORD [-28+EBP],EAX
L84:
	MOV	EAX,DWORD [8+EBX]
	CMP	DWORD [-56+EBP],EAX
	JLE	L85
	MOV	DWORD [-56+EBP],EAX
L85:
	MOV	ESI,ECX
	CMP	ECX,DWORD [-56+EBP]
	JGE	L101
L96:
	MOV	EDI,DWORD [16+EBX]
	MOV	ECX,DWORD [-24+EBP]
	ADD	EDI,ESI
	CMP	ECX,DWORD [-28+EBP]
	MOV	DWORD [-20+EBP],EDI
	JGE	L103
L95:
	MOV	EDX,DWORD [8+EBP]
	MOV	EDI,DWORD [-20+EBP]
	MOV	EAX,DWORD [12+EBX]
	IMUL	EDI,DWORD [8+EDX]
	ADD	EAX,ECX
	MOV	EDX,DWORD [-40+EBP]
	ADD	EAX,EDI
	MOV	EDI,DWORD [-44+EBP]
	MOV	DWORD [-52+EBP],EAX
	CMP	DWORD [EDX+EAX*4],EDI
	JE	L108
L92:
	INC	ECX
	CMP	ECX,DWORD [-28+EBP]
	JL	L95
L103:
	INC	ESI
	CMP	ESI,DWORD [-56+EBP]
	JL	L96
L101:
	MOV	ESI,DWORD [32+EBP]
	INC	DWORD [-16+EBP]
	CMP	DWORD [-16+EBP],ESI
	JLE	L97
L99:
	ADD	ESP,44
	POP	EBX
	POP	ESI
	POP	EDI
	POP	EBP
	RET
L108:
	MOV	EAX,ESI
	MOV	EDX,DWORD [-32+EBP]
	IMUL	EAX,DWORD [4+EBX]
	ADD	EAX,ECX
	MOV	EDI,DWORD [-52+EBP]
	MOV	EAX,DWORD [EDX+EAX*4]
	MOV	EDX,DWORD [-36+EBP]
	MOV	DWORD [EDX+EDI*4],EAX
	JMP	L92
L107:
	XOR	ECX,ECX
	JMP	L83
L106:
	MOV	DWORD [-24+EBP],0
	JMP	L82
L105:
	MOV	DWORD [16+EBP],0
	JMP	L75
L104:
	MOV	DWORD [12+EBP],0
	JMP	L74
	GLOBAL	_sheet_updown
_sheet_updown:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EDI
	PUSH	ESI
	PUSH	EBX
	PUSH	ECX
	MOV	EDI,DWORD [8+EBP]
	MOV	EBX,DWORD [12+EBP]
	MOV	ESI,DWORD [32+EDI]
	MOV	EAX,DWORD [24+EDI]
	MOV	DWORD [-16+EBP],EAX
	MOV	EAX,DWORD [16+ESI]
	INC	EAX
	CMP	EBX,EAX
	JLE	L110
	MOV	EBX,EAX
L110:
	CMP	EBX,-1
	JGE	L111
	OR	EBX,-1
L111:
	MOV	DWORD [24+EDI],EBX
	CMP	DWORD [-16+EBP],EBX
	JLE	L112
	TEST	EBX,EBX
	JS	L113
	MOV	ECX,DWORD [-16+EBP]
L118:
	MOV	EAX,DWORD [16+ESI+ECX*4]
	MOV	DWORD [20+ESI+ECX*4],EAX
	MOV	DWORD [24+EAX],ECX
	DEC	ECX
	CMP	ECX,EBX
	JG	L118
	MOV	DWORD [20+ESI+EBX*4],EDI
	INC	EBX
	PUSH	EBX
	MOV	ECX,DWORD [16+EDI]
	MOV	EAX,ECX
	ADD	EAX,DWORD [8+EDI]
	PUSH	EAX
	MOV	EDX,DWORD [12+EDI]
	MOV	EAX,EDX
	ADD	EAX,DWORD [4+EDI]
	PUSH	EAX
	PUSH	ECX
	PUSH	EDX
	PUSH	ESI
	CALL	_sheet_refreshmap
	PUSH	DWORD [-16+EBP]
L148:
	PUSH	EBX
L147:
	MOV	ECX,DWORD [16+EDI]
	MOV	EAX,ECX
	ADD	EAX,DWORD [8+EDI]
	PUSH	EAX
	MOV	EDX,DWORD [12+EDI]
	MOV	EAX,EDX
	ADD	EAX,DWORD [4+EDI]
	PUSH	EAX
	PUSH	ECX
	PUSH	EDX
	PUSH	ESI
	CALL	_sheet_refreshsub
	ADD	ESP,52
L109:
	LEA	ESP,DWORD [-12+EBP]
	POP	EBX
	POP	ESI
	POP	EDI
	POP	EBP
	RET
L113:
	MOV	EAX,DWORD [16+ESI]
	CMP	EAX,DWORD [-16+EBP]
	JLE	L120
	MOV	ECX,DWORD [-16+EBP]
	CMP	ECX,EAX
	JGE	L120
L125:
	MOV	EAX,DWORD [24+ESI+ECX*4]
	MOV	DWORD [20+ESI+ECX*4],EAX
	MOV	DWORD [24+EAX],ECX
	INC	ECX
	CMP	ECX,DWORD [16+ESI]
	JL	L125
L120:
	DEC	DWORD [16+ESI]
	PUSH	0
	MOV	ECX,DWORD [16+EDI]
	MOV	EAX,ECX
	ADD	EAX,DWORD [8+EDI]
	PUSH	EAX
	MOV	EDX,DWORD [12+EDI]
	MOV	EAX,EDX
	ADD	EAX,DWORD [4+EDI]
	PUSH	EAX
	PUSH	ECX
	PUSH	EDX
	PUSH	ESI
	CALL	_sheet_refreshmap
	MOV	EAX,DWORD [-16+EBP]
	DEC	EAX
	PUSH	EAX
	PUSH	0
	JMP	L147
L112:
	CMP	DWORD [-16+EBP],EBX
	JGE	L109
	CMP	DWORD [-16+EBP],0
	JS	L128
	MOV	ECX,DWORD [-16+EBP]
	CMP	ECX,EBX
	JGE	L144
L133:
	MOV	EAX,DWORD [24+ESI+ECX*4]
	MOV	DWORD [20+ESI+ECX*4],EAX
	MOV	DWORD [24+EAX],ECX
	INC	ECX
	CMP	ECX,EBX
	JL	L133
L144:
	MOV	DWORD [20+ESI+EBX*4],EDI
L134:
	PUSH	EBX
	MOV	ECX,DWORD [16+EDI]
	MOV	EAX,ECX
	ADD	EAX,DWORD [8+EDI]
	PUSH	EAX
	MOV	EDX,DWORD [12+EDI]
	MOV	EAX,EDX
	ADD	EAX,DWORD [4+EDI]
	PUSH	EAX
	PUSH	ECX
	PUSH	EDX
	PUSH	ESI
	CALL	_sheet_refreshmap
	PUSH	EBX
	JMP	L148
L128:
	MOV	ECX,DWORD [16+ESI]
	CMP	ECX,EBX
	JL	L146
L139:
	MOV	EDX,DWORD [20+ESI+ECX*4]
	LEA	EAX,DWORD [1+ECX]
	MOV	DWORD [24+ESI+ECX*4],EDX
	DEC	ECX
	MOV	DWORD [24+EDX],EAX
	CMP	ECX,EBX
	JGE	L139
L146:
	MOV	DWORD [20+ESI+EBX*4],EDI
	INC	DWORD [16+ESI]
	JMP	L134
	GLOBAL	_sheet_refresh
_sheet_refresh:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EBX
	MOV	EBX,DWORD [8+EBP]
	MOV	EAX,DWORD [24+EBX]
	TEST	EAX,EAX
	JS	L149
	PUSH	EAX
	PUSH	EAX
	MOV	ECX,DWORD [16+EBX]
	MOV	EAX,ECX
	ADD	ECX,DWORD [16+EBP]
	ADD	EAX,DWORD [24+EBP]
	PUSH	EAX
	MOV	EDX,DWORD [12+EBX]
	MOV	EAX,EDX
	ADD	EDX,DWORD [12+EBP]
	ADD	EAX,DWORD [20+EBP]
	PUSH	EAX
	PUSH	ECX
	PUSH	EDX
	PUSH	DWORD [32+EBX]
	CALL	_sheet_refreshsub
	ADD	ESP,28
L149:
	MOV	EBX,DWORD [-4+EBP]
	LEAVE
	RET
	GLOBAL	_sheet_slide
_sheet_slide:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EDI
	PUSH	ESI
	PUSH	EBX
	PUSH	EBX
	MOV	EBX,DWORD [8+EBP]
	MOV	EAX,DWORD [32+EBX]
	MOV	EDI,DWORD [12+EBX]
	MOV	DWORD [-16+EBP],EAX
	MOV	ESI,DWORD [16+EBX]
	MOV	EAX,DWORD [12+EBP]
	MOV	DWORD [12+EBX],EAX
	MOV	EAX,DWORD [16+EBP]
	MOV	DWORD [16+EBX],EAX
	CMP	DWORD [24+EBX],0
	JS	L151
	PUSH	0
	MOV	EAX,ESI
	ADD	EAX,DWORD [8+EBX]
	PUSH	EAX
	MOV	EAX,EDI
	ADD	EAX,DWORD [4+EBX]
	PUSH	EAX
	PUSH	ESI
	PUSH	EDI
	PUSH	DWORD [-16+EBP]
	CALL	_sheet_refreshmap
	MOV	EAX,DWORD [16+EBP]
	PUSH	DWORD [24+EBX]
	ADD	EAX,DWORD [8+EBX]
	PUSH	EAX
	MOV	EAX,DWORD [12+EBP]
	ADD	EAX,DWORD [4+EBX]
	PUSH	EAX
	PUSH	DWORD [16+EBP]
	PUSH	DWORD [12+EBP]
	PUSH	DWORD [-16+EBP]
	CALL	_sheet_refreshmap
	MOV	EAX,DWORD [24+EBX]
	ADD	ESP,48
	DEC	EAX
	PUSH	EAX
	MOV	EAX,ESI
	PUSH	0
	ADD	EAX,DWORD [8+EBX]
	PUSH	EAX
	MOV	EAX,EDI
	ADD	EAX,DWORD [4+EBX]
	PUSH	EAX
	PUSH	ESI
	PUSH	EDI
	PUSH	DWORD [-16+EBP]
	CALL	_sheet_refreshsub
	MOV	EAX,DWORD [16+EBP]
	PUSH	DWORD [24+EBX]
	PUSH	DWORD [24+EBX]
	ADD	EAX,DWORD [8+EBX]
	PUSH	EAX
	MOV	EAX,DWORD [12+EBP]
	ADD	EAX,DWORD [4+EBX]
	PUSH	EAX
	PUSH	DWORD [16+EBP]
	PUSH	DWORD [12+EBP]
	PUSH	DWORD [-16+EBP]
	CALL	_sheet_refreshsub
	ADD	ESP,56
L151:
	LEA	ESP,DWORD [-12+EBP]
	POP	EBX
	POP	ESI
	POP	EDI
	POP	EBP
	RET
	GLOBAL	_sheet_free
_sheet_free:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EBX
	MOV	EBX,DWORD [8+EBP]
	CMP	DWORD [24+EBX],0
	JS	L154
	PUSH	-1
	PUSH	EBX
	CALL	_sheet_updown
	POP	EAX
	POP	EDX
L154:
	MOV	DWORD [28+EBX],0
	MOV	EBX,DWORD [-4+EBP]
	LEAVE
	RET
